home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / tp_asm22.arc / TP&ASM.DOC < prev    next >
Text File  |  1991-04-28  |  20KB  |  520 lines

  1.  
  2.   TP&Asm           Integrated Compile-Time Assembler          Version 2.2
  3.  
  4.                 Copyright (c) 1989  Richard W. Prescott
  5.                           All Rights Reserved
  6.  
  7. ═══════ Built-In Assembly Language Support for Turbo Pascal Compilers ═══════
  8.  
  9.  All brand and product names mentioned herein are trademarks or registered 
  10.                 trademarks of their respective holders.
  11.  
  12.   ┌─────────────────────────────────────────────────────────────────────┐
  13.   │  This file contains information of a general nature, including      │
  14.   │  getting started quickly, and purchasing TP&Asm.  For detailed      │
  15.   │  reference information to enable you to make most effective use of  │
  16.   │  the TP&Asm assembly environment, please see the archive TP-AsR     │
  17.   └─────────────────────────────────────────────────────────────────────┘
  18.  
  19.  
  20. The following topics are described below:
  21.  
  22. 1. Overview
  23. 2. Features
  24. 3. System Requirements
  25. 4. Getting Started
  26. 5. Comparison of Methods
  27. 6. Quality Control
  28. 7. DISCLAIMER
  29. 8. Purchase Information
  30.  
  31.  
  32.  
  33.  
  34. Note:
  35.  
  36. This archive contains a complete, unlimited version of TP&Asm which is 
  37. being distributed as "shareware".  No features have been disabled, and
  38. nothing has been omitted from the documentation contained in this file
  39. or in the separate reference archive.  It differs from the version you
  40. get when you register only in that it contains a reminder to register,
  41. which pops up the first time you compile to disk after running TP&Asm.
  42. (Registered users also receive the source code for EXAMINE.EXE and the 
  43. WCHMGR5x.TPU files).
  44.  
  45. Except for this distinction, all references to TP&Asm or TPA.EXE apply
  46. to the program file TPA(E).EXE contained in this archive. You may find
  47. it convenient to rename  TPA(E).EXE to TPA.EXE, however please use the
  48. original name whenever you redistribute this archive.
  49.  
  50. If you like this program, and use it, then please order a registered 
  51. copy.  As an incentive to register early, I am offering a $10 discount
  52. to all orders received by 8/31/89:
  53.  ┌─────────────────────────────────────────────────────────────────┐
  54.  │ TP&Asm Version 2.2: $39 + $3 P&H  Reduced Price (until 8/31/89) │
  55.  └─────────────────────────────────────────────────────────────────┘
  56. Please see section 8 for further registration information.
  57.  
  58.  
  59.  
  60.  
  61. 1. Overview
  62.  
  63. TP&Asm is an integrated assembler for Turbo Pascal versions 5.5, 5.0,
  64. and 4.0 which operates during the compile step to provide support for 
  65. the four TP&Asm keywords "Assemble" (or "Assembly"), "Internal", 
  66. "CsData", and "Asm":
  67.  
  68.       Assemble                       Internal <DataName>
  69.         :                              :
  70.         (Assembly                      (Assembly
  71.          Instructions)                  Instructions)
  72.         :                              :
  73.       End;                           End;
  74.  
  75.  
  76.       CsData
  77.         :
  78.         (Db, Dw, or Dd
  79.          Statements)
  80.         :
  81.       End;
  82.  
  83.  
  84.       Asm <Assembly Statement>;
  85.  
  86.  
  87. Briefly:
  88.  
  89.   "Assemble" defines a block of standard 8086 assembly language
  90.     statements which can be placed wherever an Inline statement 
  91.     would be valid (including 'Inline Directives').  
  92.  
  93.   "Internal" provides support for assembly language code originally 
  94.     designed for an external assembler.  
  95.  
  96.   "CsData" defines a block of initialized or uninitialized data
  97.     which is allocated in the current Code segment and is 
  98.     accessable throughout the current Unit (used primarily with
  99.     customized interrupt procedures and resident applications). 
  100.  
  101.   "Asm" provides a concise way of specifying single-line assembly
  102.     sections.
  103.  
  104.  
  105. As of Version 2.2, the following compilers are supported:
  106.  
  107.       TURBO.EXE    Versions 5.5, 5.0, and 4.0
  108.       TPC.EXE      Versions 5.5, 5.0, and 4.0
  109.  
  110.  
  111. Example:
  112.  
  113. The following simple functions compile successfully when a 
  114. supported compiler is run under TP&Asm: 
  115.  
  116.   FUNCTION ReadScan:Byte; {Read keyboard scan code without echo to screen}
  117.    Assembly             {- Inline Directive -}
  118.     Mov Ah,0
  119.     Int 16h
  120.     Mov Al,Ah           ;Put Assembly/Inline Directive result in Al
  121.    END; {Assembly}
  122.  
  123.  - or -
  124.  
  125.   FUNCTION ReadScan:Byte; {Read keyboard scan code without echo to screen}
  126.   BEGIN                 {- Standard Callable Function -}
  127.    Assembly 
  128.     Mov Ah,0
  129.     Int 16h
  130.     Mov ReadScan,Ah     ;Put in standard function results by name
  131.    END; {Assembly}
  132.   END; {FUNCTION ReadScan}
  133.  
  134.  
  135. Please see the various PAS files in this archive for further
  136. examples.
  137.  
  138.  
  139.  
  140. 2. Features of TP&Asm
  141.  
  142.  o Runs Turbo/TPC as a subprocess.  Simple to use, yet powerful 
  143.    enough to run ANY command line under TP&Asm.  For example, 
  144.    "tpa C:\Command" can be used to make TP&Asm "Memory resident".
  145.    See the reference archive TP-AsR. 
  146.  
  147.  o Compact: Program size 44K, TOTAL Memory usage less than 54K 
  148.    (Frees its own "environment" block for reuse by the subprocess) 
  149.  
  150.    - yet -
  151.  
  152.  o Imposes NO limits on Source Code size, Object Code size, or Data 
  153.    Seg symbols.  (Your program must still satisfy any Compiler 
  154.    limits, however) 
  155.  
  156.  o Fast Assembly from Memory - TP&Asm imposes NO additional disk
  157.    access time, even for Include files.
  158.  
  159.  o Fully compatible with the Turbo 5.0/5.5 integrated debugger.  
  160.    The units WCHMGR5x (included) allow you to Watch, Evaluate, and
  161.    Modify the state of all CPU registers and flags.
  162.  
  163.  o Fully integrated with the Turbo built-in Linker.  Permits direct
  164.    Call, Jmp, and Offset references to Pascal Proc/Functions.
  165.    (These references are recognized by the Turbo Smart Linker).
  166.  
  167.    - yet -
  168.  
  169.    Units compiled with TP&Asm may be Used in any Turbo Pascal 
  170.    program compiled with or without TP&Asm.
  171.  
  172.  o Fully supports references to Turbo 5.5 objects and methods.
  173.    Supports Static and Virtual method calls BY NAME rather than 
  174.    user-calculated VMT offsets, as well as assembly references to
  175.    "Self" and "VMT".  You can redesign any object structure without
  176.    rewriting any (TP&Asm) assembly code.  (Not so with External!)
  177.  
  178.  o Freely mix Pascal and assembly sections.  Pascal Labels placed
  179.    in assembly sections can be the target of any GOTO statement.
  180.    Assembly statements can branch to (Jmp, Loop, jNZ, etc) or Call
  181.    any Pascal or assembly label.
  182.  
  183.  o Performs automatic Jump-Sizing for all backward AND FORWARD
  184.    Jumps and Loops.  Always builds smallest possible instruction
  185.    (does not pad code with NOPs).
  186.  
  187.  o Supports all 8086 Assembly mnemonics and all assembler directives 
  188.    that make sense within a Turbo Pascal program.  
  189.  
  190.  o Supports numerous extensions for compatibility with Eric 
  191.    Isaacson's A86 Assembler (Multiple operands to Push, IF's, Local 
  192.    Labels, etc).
  193.  
  194.  o Recognizes all common decimal and hexidecimal numeric formats, 
  195.    including leading '$' for compatibility with Dave Baldwin's 
  196.    INLINE.COM.  
  197.  
  198.  o Automatically supplies correct segment override and base register 
  199.    needed to reference most Pascal and Assembly variables.  (This 
  200.    feature may be disabled for "WYSIWYG" assembly).  
  201.  
  202.  o Allows setting function results by name, e.g.: 
  203.    "Mov FunctionName,TRUE" (Automatically recognizes Built-In 
  204.    compiler symbols such as TRUE).  
  205.  
  206.  o Provides extensive syntax error checking, completely integrated 
  207.    with the compiler's syntax checking.  The cursor is placed at the 
  208.    point in your assembly language code where the error occurred.  
  209.  
  210.  o Supports Warning level errors, with option to Ignore or Halt on 
  211.    warnings.  
  212.  
  213.  o Does not disable "Inline" or "External" - these keywords are 
  214.    still available, but are no longer necessary.  Any or all of
  215.    the keywords Assemble, Internal, External, and Inline may be
  216.    used in each program or unit.
  217.  
  218.  
  219.  
  220. 3. System Requirements
  221.  
  222. TP&Asm Version 2.2 requires: the IBM PC version of Turbo Pascal 5.5,
  223. 5.0, or 4.0 running on an IBM PC or Compatible, with Version 2.0 or 
  224. above of MS-DOS or PC-DOS.  Minimum memory requirements are 54K more 
  225. than the memory required by the compiler.  
  226.   
  227.  
  228.  
  229. 4. Getting Started
  230.  
  231. Simply type 'tpa' { or 'tpa(e)' } in place of 'turbo' at the system 
  232. prompt.  TP&Asm will automatically find and run turbo.exe, using 
  233. the same search sequence as DOS.  Or run the command line compiler
  234. by typing 'tpa tpc progname' or 'tpa c progname'.  (See the archive 
  235. TP-AsR for other command line options when starting TP&Asm).  
  236.  
  237. Now read in some of the test files.  Browse through them to see 
  238. what they do, then compile and run them.  Modify them and run again.  
  239. Version 5.0 and 5.5 users, use F7 "Trace into" to step through the
  240. file DEMOTPA.PAS (which automatically sets up a series of assembly 
  241. level watch expressions) and observe the CPU registers and flags 
  242. as you trace through the assembly code.  Observe how easy it is to 
  243. experiment with assembly language in your programs.  Observe the 
  244. response to syntax errors.  TP&Asm does not intrude into your 
  245. programming environment - you are running Turbo Pascal, and the 
  246. assembler is integrated so smoothly into the system that you may 
  247. forget you are using it.  It is active, however, every time the 
  248. compiler calls upon it to translate an Assemble or Internal 
  249. statement.  
  250.  
  251.  
  252.  
  253. 5. A Comparison of (Assembly Language) Methods
  254.  
  255. This section discusses advantages and disadvantages of the four 
  256. basic methods of using machine code/assembly language within a Turbo 
  257. Pascal program:  Inline and External (as provided by Turbo Pascal),
  258. and Internal and Assemble (provided by TP&Asm).  (Skip this section 
  259. if you're already convinced).  
  260.  
  261. INLINE:
  262.  
  263. The disadvantage of the Inline statement is obvious - no support for 
  264. mnemonics.  Every instruction must be assembled by hand, jumps and 
  265. loops are essentially impossible, etc.  Direct calls to Pascal
  266. Procedures and Functions are not permitted.
  267.  
  268. An advantage, however, is that code may be placed anywhere in the 
  269. code stream, not just into separate callable Proc/Functions, and 
  270. Turbo identifiers may be referenced by name.  In addition, Inline 
  271. statements may be used to define machine code MACROs.  
  272.  
  273. EXTERNAL:
  274.  
  275. The advantage of External is, just as obviously, full support of 
  276. assembly mnemonics (or whatever subset is supported by your external 
  277. assembler).  May also permit access to the symbol "SEG DATA" for 
  278. restoring the program Data Segment (useful in interrupt routines).
  279.  
  280. Disadvantages of External are:
  281.  
  282.   Code must always go into separate callable Global Proc/Functions.
  283.  
  284.   Limited support for Global Pascal identifier references.
  285.    UnitName and record component qualifiers are not permitted.
  286.    Referenced identifiers must be declared in EXTRN statements.  
  287.  
  288.   Limited "dead code removal" - Turbo Pascal links in External .OBJ 
  289.    modules in an "all or nothing" fashion.
  290.  
  291.   All references to Proc/Function parameters and Function results 
  292.    returned on the stack must be coded explicitly (not referenced 
  293.    by name) and may need to be changed for future versions of the 
  294.    compiler.  Note however that Borland's TASM provides the 
  295.    ".MODEL TPASCAL" directive which permits the same simplified
  296.    parameter references as the TP&Asm Assemble statement.
  297.  
  298.  
  299. INTERNAL:
  300.  
  301. Internal is essentially a direct replacement for External,
  302. supporting 8086 Assembly mnemonics and access to the symbol
  303. "SEG DATA".
  304.  
  305. Improvements:
  306.  
  307.   Full support for Global Pascal variable references with no need 
  308.    for EXTRN.  Supports UnitName, record component, and object 
  309.    component qualifiers.
  310.    
  311.   Fully supports direct and virtual method calls by name, rather
  312.    than by user-calculated VMT offsets, permitting insertion and 
  313.    removal of virtual methods without rewriting any assembly code.
  314.  
  315.   Full "dead code removal" on a Proc by Proc basis within each
  316.    INTERNAL statement.  Permits development of efficient libraries
  317.    of assembly routines compiled into standard Turbo Pascal TPUs.
  318.  
  319. Unchanged:
  320.  
  321.   Code still must go into separate callable Global procs.
  322.  
  323.   Parameter and function results must still be explicitly coded.
  324.  
  325.  
  326. ASSEMBLE:
  327.  
  328. Advantages:
  329.  
  330.   As with External, supports 8086 Assembly mnemonics and access to
  331.    the symbol "SEG DATA" (8087 mnemonics are not yet supported).
  332.  
  333.   As with Inline, code may be placed anywhere in the code stream, 
  334.    INCLUDING in the definition of (assembly) Inline Directive/MACROs 
  335.  
  336.   As with Internal, provides full support for global Pascal variable
  337.    references without EXTRN, including UnitName and record component
  338.    qualifiers.  Permits direct Call (or Jmp) to any Pascal or Internal 
  339.    Proc/Function, and direct or virtual calls to version 5.5 methods.
  340.  
  341.   In fact, all Pascal variables/parameters which are global or local 
  342.    to the current Proc/Function may be referenced by the standard 
  343.    Pascal name (without '[BP]', 'CS', etc.).  Function results may 
  344.    likewise be put in by name.  There is no need to be concerned 
  345.    with the details of Stack usage and parameter passing for any
  346.    particular compiler version.
  347.  
  348.   Provides capability of allocating and referencing NAMED 
  349.    initialized (or uninitialized) data in the current code seg.
  350.  
  351.  
  352. To summarize,
  353.  
  354.  In terms of coding convenience:
  355.     - External is a major improvement over Inline
  356.     - Internal is a moderate improvement over External
  357.     - Assemble is a major improvement over Internal and External
  358.  
  359.  In terms of flexibility of use, however, Assemble and Inline have 
  360.  advantages over External and Internal.
  361.  
  362.  
  363. It should be clear at this point that the Assemble statement provides 
  364. the most versatile and convenient means of including assembly 
  365. language in your programs.  Now consider the fact that with Assemble 
  366. (and Internal) you don't need to leave the compiler at any point 
  367. during your program development, and you can see that TP&Asm offers 
  368. you an immense improvement in program development speed.  The time 
  369. consuming assembly development loop of:
  370. Exit Turbo/ Assemble/ Reenter Turbo/ Compile &/or Link/ Test/ Repeat
  371. is replaced by the simple and familiar  Edit/Run/Repeat  loop.
  372. With TP&Asm you can be wrapped up & on your way home while others 
  373. are still watching their assemblers clean up temporary disk files.
  374.  
  375. Or if you primarily use TPC, consider how many ASM and OBJ files you
  376. have littering your directories.  With TP&Asm you can put all related
  377. assembly routines into a single PAS file and compile to a single TPU
  378. which provides Proc by Proc Smart-Linking and can be automatically 
  379. rebuilt by TPC whenever you modify your assembly source code.
  380.  
  381. Even if your primary goal is to write stand-alone assembly programs,
  382. consider the advantage of using Turbo/TP&Asm as a program 
  383. development environment.  You can develop, test and debug your 
  384. assembly routines using all the power and flexibility of Pascal in 
  385. the testing process - then port your code unchanged** to A86 or 
  386. your favorite stand-alone assembler.  See, for example, HEXBYTE.PAS.
  387.  
  388. ** regarding compatability:  essentially, it is a simple matter to 
  389.    design your code so that it requires NO changes in porting from 
  390.    TP&Asm to A86, MASM, TASM, or any assembler that is reasonably 
  391.    compatible with one of these.  You must of course avoid using 
  392.    any TP&Asm enhancements that are not supported by your assembler.  
  393.  
  394.  
  395.  
  396. The paragraphs above address the issue of why you should use TP&Asm 
  397. when you use assembly language ... but why use assembly language at 
  398. all?
  399.  
  400. The principal reasons for using assembly language in a Pascal 
  401. program are: 
  402.  
  403.   1) To do something that cannot be done in Pascal.  This might
  404.      involve a resident application, or some sort of direct
  405.      interaction with the system hardware.  See for example the 
  406.      archives TP-TSR and TP-TRC described in the README file.
  407.  
  408.   2) To do something much faster than it can be done in Pascal.
  409.      The file FIND.PAS provides a demonstration.
  410.  
  411.   3) To minimize code size or stack requirements, especially for 
  412.      "memory resident" programs.  (When code size is critical,
  413.      however, the entire application would probably be written
  414.      in assembly).
  415.  
  416.  
  417. With TP&Asm you can put assembly code exactly (and only) where you
  418. want it, and let the compiler handle everything else.
  419.  
  420.  
  421.  
  422. 6. Quality Control
  423.  
  424. This program has been tested by assembling over 6000 variations of 
  425. assembly language statements and running the Turbo/TP&Asm output 
  426. Exe file through EXAMINE.EXE to produce a "side by side" display 
  427. of each assembly source statement together with its corresponding 
  428. DEBUG.COM disassembly.  All modifications are retested against the 
  429. same test files.  EXAMINE.EXE is provided free of charge on the 
  430. TP&Asm distribution disk so that users may easily verify proper 
  431. assembly within their own programs.  It can also be found in the
  432. archive TP-XMN as described in the README file.  (EXAMINE requires 
  433. a compiled EXE and MAP file and a copy of DEBUG.COM).
  434.  
  435.  
  436. TP&Asm Version 2.2 is compiled and assembled using TP&Asm Version 
  437. 2.2 running Turbo Pascal Version 5.5.
  438.  
  439.  
  440.  
  441. 7. DISCLAIMER OF WARRANTY
  442.  
  443. This software and accompanying documentation are sold "as is" and 
  444. without warranties as to performance or merchantability.
  445.  
  446. This program is sold without any express or implied warranties 
  447. whatsoever.  Because of the diversity of conditions and hardware 
  448. under which this program may be used, no warranty of fitness for a 
  449. particular purpose is offered.  The user is advised to test the 
  450. program thoroughly before relying on it.  THE USER MUST ASSUME THE 
  451. ENTIRE RISK OF USING THE PROGRAM.  ANY LIABILITY OF THE AUTHOR WILL 
  452. BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF THE 
  453. PURCHASE PRICE.  
  454.  
  455.  
  456.  
  457. 8. Purchase Information.
  458.  
  459. After you have reviewed the TP&Asm package for a reasonable period 
  460. of time (say, 30 days), please register it if you plan to continue 
  461. using it.  Even if you choose not to register, I encourage you to 
  462. retain a copy of TP&Asm and distribute it to others via BBS or on 
  463. diskette.  Please include all files in both this archive and the 
  464. reference archive TP-AsR (if you have it). 
  465.  
  466. If you find that this software does not perform as described, please 
  467. let me know.  I am proud of this program and I want it to work right 
  468. for you.  If you are dissatisfied, I will refund your purchase price.
  469. I only ask that you clearly state the manner in which it failed to 
  470. perform as described when you return the distribution disk (and, of 
  471. course, that you discontinue using the program).  I will accept your 
  472. judgement without argument.  Consider the spirit in which this offer 
  473. is made, and please be fair.
  474.  
  475.  
  476. The current prices are as follows:
  477.  
  478. TP&Asm Version 2.2  ... $39 + $3 P&H  Reduced Price (until 8/31/89)
  479.                     ... $49 + $3 P&H  Regular Price (after 8/31/89)
  480.  
  481. Registered owners of any TP&Asm version can receive a full upgrade 
  482. to TP&Asm version 2.2 for $5 + $3 P&H.
  483.  
  484.  
  485. Wisconsin residents, please add 5% sales tax.  Overseas orders, 
  486. please send a bank check in $US.
  487.  
  488. All prices listed are for standard 5 1/4 inch floppy disks.  Add
  489. $2 for distribution on 3 1/2 inch disks.
  490.  
  491.  
  492. Please send a check or money order payable to:
  493.  
  494.                       Richard W. Prescott
  495.                       21 Mondale Court
  496.                       Madison, WI  53705
  497.  
  498. Please include the following information:
  499.  
  500.   1. Full Version number of the Turbo Pascal compiler you now use.
  501.  
  502.   2. (Optional) Your registration number for that compiler.  This 
  503.      could be useful in tracking problem reports.  
  504.  
  505.   3. If you obtained TP&Asm from a bulletin board:
  506.      3a. Name, area code and phone number of that bulletin board
  507.      3b. Full Version number of the TP&Asm version you have
  508.      3c. Directory Date of the README file
  509.  
  510.  
  511.  
  512.  
  513.  
  514. The full shareware package, including this archive, the reference 
  515. archive, and the archive TP-XMN, is available for $5 + $3 P&H.
  516. Use this option if it's cheaper than your connect charges, or if
  517. you feel more comfortable getting the software directly from me.
  518. If you subsequently decide to register you may deduct $5 from the 
  519. above listed prices.
  520.